﻿using System;
using System.Runtime.Serialization;

namespace XMLFT
{
    /// <summary>
    /// Exception Class for XMLFT.
    /// Documentation I read on creating this custom Exception Class can be found at:
    /// http://blog.gurock.com/articles/creating-custom-exceptions-in-dotnet/
    /// </summary>
    [Serializable]
    class XMLFTException : System.Exception
    {
        // FIXME : Need to add custom objects for Template File, Control Info, etc.
        private string tFilename;

        /// <summary>
        /// Default Constructor
        /// </summary>
        public XMLFTException()
        {
        }

        public XMLFTException(string message): base(message)
        {
        }

        public XMLFTException(string message, Exception innerException) : base(message, innerException)
        {
        }

        protected XMLFTException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            if (info != null)
            {
                this.tFilename = info.GetString("tFilename");
            }
        }

        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);

            if (info != null)
            {
                info.AddValue("tFilename", this.tFilename);
            }
        }

        public string TemplateFile
        {
            get { return this.tFilename; }
            set { this.tFilename = value; }
        }
    }
}
